package com.myapp.ruyixing.http;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.myapp.ruyixing.model.ShopPicList;
import com.myapp.ruyixing.model.ShopPicList.ShopPic;

public class ShopPicListParser extends RYJSONParser {
	@Override
	public Object parse(JSONObject jsonObject) {
		ShopPicList picList = new ShopPicList();

		ListModelParser.parseListModel(picList, jsonObject);
		JSONObject data = jsonObject.optJSONObject("data");
		JSONArray array = data.optJSONArray("items");
		picList.items = new ArrayList<ShopPicList.ShopPic>();
		for (int i = 0; array != null && i < array.length(); i++) {
			JSONObject object = array.optJSONObject(i);
			if (object != null) {
				ShopPic shopPic = new ShopPic();
				shopPic.picurl = object.optString("picurl", "");
				shopPic.datetime = object.optString("datetime", "");
				shopPic.id = object.optString("id", "");
				shopPic.name = object.optString("name", "");
				shopPic.type = object.optString("type", "");
				picList.items.add(shopPic);
			}
		}

		return picList;

	}
}
